class Book < ActiveRecord::Base
  belongs_to :genre
  belongs_to :subgenre
  belongs_to :publisher
  belongs_to :language
  belongs_to :publisher
  has_and_belongs_to_many :authors
  
  validates_length_of :title, :within => 1..140, :on => :save
  validates_length_of :original_title, :within => 1..140, :on => :save

  def author= (author)
    authors.clear
    author.uniq!
    author.each {|a| self.authors << Author.find(a)}
  end
end